#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 1e5+10;
const int M = 3 * N;

int u[M],v[M],a[N],n,m,deg[N];
vec G[N];
int vis[N];
ll ans;

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in; for(int i = 1;i <= n;i++) a[i] = in;
	for(int i = 1;i <= m;i++) u[i] = in,v[i] = in,deg[u[i]]++,deg[v[i]]++;
	for(int i = 1;i <= m;i++){
		if(deg[u[i]] < deg[v[i]] || (deg[u[i]] == deg[v[i]] && u[i] < v[i])) swap(u[i],v[i]);
		G[u[i]].pb(v[i]);
	}
	for(int x = 1;x <= n;x++){
		for(auto y : G[x]) vis[y] = x;
		for(auto y : G[x])
			for(auto z : G[y])
				if(vis[z] == x) ans += max(a[x],max(a[y],a[z]));
	}
	printf("%lld\n",ans);
	return 0;
}
